<?php

declare(strict_types=1);

namespace App\Exchange\Job;

use App\Exchange\Api\WebSocketServer;
use Hyperf\AsyncQueue\Job;

class SendContractKlineJob extends Job
{
    public function __construct(public string $msg, public string $e, public string $symbol)
    {
    }

    public function handle()
    {
        $fds = redis()->sMembers('ex:contract:' . $this->symbol);
        foreach ($fds as $fd) {
            try {
                WebSocketServer::sendMsg((int)$fd, $this->e, $this->msg);
            } catch (\Throwable $throwable) {
                console()->error('SendContractKlineJob---' . $throwable->getMessage());
            }
        }
    }
}
